package Vue;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;

import Modele.MonteCarloSimulation;
import Modele.MonteCarloSimulationMulti;

import java.util.ArrayList;

public class Fenetre extends JFrame{
	
	private static JComboBox combo=new JComboBox();
	private static JComboBox combo2=new JComboBox();
	private JLabel JLresult;
	private JTabbedPane onglet;
	private JProgressBar bar;
	private JButton boutonGO = new JButton("Go");
	private JButton boutonGO2= new JButton("Go2");
	private JButton bouton2 = new JButton("Stop");
	private JLabel label = new JLabel("     Selectionnez votre option :");
	private JLabel label2 = new JLabel("     Selectionnez votre option :");
	private JLabel label3 = new JLabel("     Modifier les valeurs par defaults :");
	private JLabel label4 = new JLabel(" ");
	private JLabel label5 = new JLabel("   ");
	private JPanel pan = new JPanel(); 
	private JPanel panMono=new JPanel(new GridLayout(4, 3));
	private JPanel panMulti= new JPanel(new GridLayout(4, 3));
	private MonteCarloSimulation mcs=new MonteCarloSimulation() ;
	private JButton boutonPlus=new JButton("modifier");
	private String resu;
	
	//multi
	private static JComboBox Mcombo=new JComboBox();
	private static JComboBox Mcombo2=new JComboBox();
	private JLabel MJLresult;
	private JTabbedPane Monglet;
	private JProgressBar Mbar;
	private JButton MboutonGO = new JButton("Go");
	private JButton MboutonGO2= new JButton("Go2");
	private JButton Mbouton2 = new JButton("Stop");
	private JLabel Mlabel = new JLabel("     Selectionnez votre option :");
	private JLabel Mlabel2 = new JLabel("     Selectionnez votre option :");
	private JLabel Mlabel3 = new JLabel("     Modifier les valeurs par defaults :");
	private JLabel Mlabel4 = new JLabel(" ");
	private JLabel Mlabel5 = new JLabel("   ");
	//private JPanel Mpan = new JPanel(); 
	private JPanel MpanMono=new JPanel(new GridLayout(4, 3));
	private JPanel MpanMulti= new JPanel(new GridLayout(4, 3));
	private MonteCarloSimulationMulti Mmcs=new MonteCarloSimulationMulti() ;
	private JButton MboutonPlus=new JButton("modifier");
	private String Mresu;
	 
	public Fenetre(){
		//on créer deux onglets
		onglet=new JTabbedPane();
		onglet.add("MonoThread",panMono);
		onglet.add("MultiThread",panMulti);
		
	//MONOTHREAD
		bar=new JProgressBar();
		bar.setStringPainted(true);
		combo.addItem("call");
		combo.addItem("putt");
		combo.setForeground(Color.blue);
		combo2.addItem("Simulation 1");
		combo2.addItem("Simulation 2");
		combo2.addItem("Simulation 3");
		combo2.addItem("Simulation 4");
		combo2.addItem("Simulation 5");
		JLresult=new JLabel("0.0");
		
	//MULTHITHREAD
		Mbar=new JProgressBar();
		Mbar.setStringPainted(true);
		Mcombo.addItem("call");
		Mcombo.addItem("putt");
		Mcombo.setForeground(Color.blue);
		Mcombo2.addItem("Simulation 1");
		Mcombo2.addItem("Simulation 2");
		Mcombo2.addItem("Simulation 3");
		Mcombo2.addItem("Simulation 4");
		Mcombo2.addItem("Simulation 5");
		MJLresult=new JLabel("0.0");
		
	//MONOTHREAD
		panMono.add(label);
		panMono.add(combo);
		panMono.add(boutonGO);
		panMono.add(label2);
		panMono.add(combo2);
		panMono.add(boutonGO2);
		panMono.add(label3);
		panMono.add(boutonPlus);
		panMono.add(label4);
		panMono.add(label5);
		panMono.add(JLresult);
		panMono.add(bar);
		
		// MULTITHREAD
		panMulti.add(Mlabel);
		panMulti.add(Mcombo);
		panMulti.add(MboutonGO);
		panMulti.add(Mlabel2);
		panMulti.add(Mcombo2);
		panMulti.add(MboutonGO2);
		panMulti.add(Mlabel3);
		panMulti.add(MboutonPlus);
		panMulti.add(Mlabel4);
		panMulti.add(Mlabel5);
		panMulti.add(MJLresult);
		panMulti.add(Mbar);
		
		
		this.setContentPane(pan);
		this.getContentPane().add(onglet);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setBounds(0, 0, 750, 200);
		this.setLocationRelativeTo(null);
		this.setTitle("MonteCarlo");
		this.setVisible(true);	
	}
	
	
	// LISTENER SUR MONOTHREAD
	public void comboListener(ActionListener listenForCalcButton){
		combo.addActionListener(listenForCalcButton);
	
		
	}
	
	public void boutonGOListener(ActionListener listenForCalcButton){
		boutonGO.addActionListener(listenForCalcButton);
	
	
	}
	public void boutonGO2Listener(ActionListener listenForCalcButton){
		boutonGO2.addActionListener(listenForCalcButton);
		
	}
	public void boutonPlusListener(ActionListener listenForCalcButton){
		boutonPlus.addActionListener(listenForCalcButton);
	}  
	
	//LISTENER SUR MULTITHREAD
	public void McomboListener(ActionListener listenForCalcButton){
		Mcombo.addActionListener(listenForCalcButton);
	}
	
	public void MboutonGOListener(ActionListener listenForCalcButton){
		MboutonGO.addActionListener(listenForCalcButton);
	
	}
	public void MboutonGO2Listener(ActionListener listenForCalcButton){
		MboutonGO2.addActionListener(listenForCalcButton);
		
	}
	public void MboutonPlusListener(ActionListener listenForCalcButton){
		MboutonPlus.addActionListener(listenForCalcButton);
	}  
	
	// MONOTHREAD: GETTER AND SETTER
	public static JComboBox getCombo() {
		return combo;
	}

	public void setCombo(JComboBox combo) {
		this.combo = combo;
	}
	
	public static JComboBox getCombo2() {
		return combo2;
	}

	public void setCombo2(JComboBox combo2) {
		this.combo2 = combo2;
	}
	
	public JLabel getJLresult() {
		return JLresult;
	}

	public void setJLresult(JLabel jLresult) {
		JLresult = jLresult;
	}
	
	public JProgressBar getBar() {
		return bar;
	}

	public void setBar(JProgressBar bar) {
		this.bar = bar;
	}
	
	
	// MULTITHREAS: GETTER AND SETTER
	public static JComboBox getMCombo() {
		return Mcombo;
	}

	public void setMCombo(JComboBox Mcombo) {
		this.Mcombo = Mcombo;
	}
	
	public static JComboBox getMCombo2() {
		return Mcombo2;
	}

	public void setMCombo2(JComboBox Mcombo2) {
		this.Mcombo2 = Mcombo2;
	}
	
	public JLabel getMJLresult() {
		return MJLresult;
	}

	public void setMJLresult(JLabel MjLresult) {
		MJLresult = MjLresult;
	}
	
	public JProgressBar getMBar() {
		return Mbar;
	}

	public void setMBar(JProgressBar Mbar) {
		this.Mbar = Mbar;
	}	

}
